package com.gmadmin.controller;


import com.gmadmin.common.ApiResponse;
import com.gmadmin.service.UnitOrganizationService;
import com.gmadmin.service.vo.UnitOrganizationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "单位:组织管理")
@RestController
@RequestMapping(value = "api/unit/organization")
public class UnitOrganizationController {

    private final UnitOrganizationService service;

    public UnitOrganizationController(UnitOrganizationService service) {
        this.service = service;
    }

    @ApiOperation(value = "获取部门树")
    @GetMapping(value = "getTree")
    public ApiResponse<List<UnitOrganizationVo>> getOrganizationTree() {
        List<UnitOrganizationVo> unitOrganizationVoList = service.findOrganizationTree();
        return ApiResponse.ofSuccess(unitOrganizationVoList);
    }
}
